package cn.com.dcsgo.api;

import cn.com.dcsgo.model.order.CartInfo;
import cn.com.dcsgo.service.ActivityInfoService;
import cn.com.dcsgo.vo.order.OrderConfirmVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * ActivityInfoApiController
 *
 * @author Dcsgo
 * @since 2025/4/27 11:14
 */
@Api(tags = "促销活动")
@RequiredArgsConstructor
@RestController
@RequestMapping("api/activity")
public class ActivityInfoApiController {
    private final ActivityInfoService activityInfoService;

    @ApiOperation(value = "通过skuIds获取促销信息", notes = "返回map集合 -> skuId:[促销信息]")
    @GetMapping("sku")
    public Map<Long, List<String>> getActivitySimpleInfo(@RequestParam List<Long> ids) {
        return activityInfoService.getActivitySimpleInfoBySkuIds(ids);
    }

    @ApiOperation(value = "获取sku关联的促销信息", notes = "通过skuId和userId")
    @GetMapping("sku/{skuId}/user/{userId}/coupon")
    public Map<String, Object> getActivityAndCouponInfo(@PathVariable Long skuId,
                                                        @PathVariable Long userId) {
        return activityInfoService.getActivityAndCouponInfo(skuId, userId);
    }

    @ApiOperation("获取指定用户的购物车结算信息")
    @PostMapping("user/{userId}/cart/settlement")
    public OrderConfirmVo getCartSettlementInformation(@PathVariable Long userId, @RequestBody List<CartInfo> items) {
        return activityInfoService.getCartSettlementInformation(userId, items);
    }
}
